/**
 * 导入依赖库
 */
import Vue from 'vue'
import App from './App'
import store from '@/store'
import config from '@/config/index'
import * as utils from '@/utils/index'
import * as apis from '@/api/index'
import { i18n } from '@/i18n'
import mixin from '@/utils/mixin/mixin'
import uView from '@/uni_modules/uview-ui'
import dayjs from 'dayjs'

/**
 * 全局过滤器
 */
Vue.filter('dateFormat', (date, format = 'YYYY/MM/DD HH:mm') => {
  return dayjs(date).format(format)
})
Vue.filter('numberFormat', (value, digits = 2) => {
  return (Math.floor((Number(value) || 0) * 100) / 100).toFixed(digits)
})

/**
 * 挂载全局组件和全局混入
 */
Vue.use(uView)
Vue.mixin(mixin)

/**
 * 挂载原型属性
 */
Vue.prototype.$store = store
Vue.prototype.$config = config
Vue.prototype.$utils = utils
Vue.prototype.$api = apis
Vue.prototype._i18n = i18n
Vue.prototype.$dayjs = dayjs

if (process.env.NODE_ENV === 'production') {
  Vue.config.productionTip = false
}

App.mpType = 'app'

const app = new Vue({
  store,
  ...App,
})

require('@/config/request.js')(app)

app.$mount()
